//
//  WuLiRequestFlowStar.m
//  WULIHH
//
//  Created by tang on 16/4/14.
//  Copyright © 2016年 tang. All rights reserved.
//

#import "WuLiRequestFlowStar.h"
#import "AFNetworking.h"
#import "Header.h"

#import "UserInfoModel.h"

@implementation WuLiRequestFlowStar


//请求用户关注明星
+ (id)requestFlowStarWithUserID:(NSString *)UserID
{
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    
    [manager.requestSerializer setValue:[UserInfoModel tokenString] forHTTPHeaderField:@"X-AUTH-TOKEN"];
    [manager.requestSerializer setValue:appVersion forHTTPHeaderField:@"X-APP-VERSON"];
    [manager.requestSerializer setValue:typetext forHTTPHeaderField:@"Content-Type"];
    
    NSString *httpString = [NSString stringWithFormat:@"%@%@%@/%@/",hostName, getFlowStarAPI, UserID, @"follow"];
    
    
        NSLog(@"%@", httpString);
    [manager GET:httpString parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
        // 这里可以获取到目前的数据请求的进度
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        // 请求成功，解析数据
        //        NSLog(@"%@", responseObject);
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers | NSJSONReadingMutableLeaves error:nil];
        [[NSNotificationCenter defaultCenter] postNotificationName:getFloeStar object:nil userInfo:dic];
//        NSLog(@"%@", dic);
        
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        // 请求失败
                NSLog(@"%@", [error localizedDescription]);
    }];

    return self;
}


//请求用户关注明星
+ (id)requestAddFlowStarWithUserID:(NSString *)StarID
{
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    
    [manager.requestSerializer setValue:[UserInfoModel tokenString] forHTTPHeaderField:@"X-AUTH-TOKEN"];
    [manager.requestSerializer setValue:appVersion forHTTPHeaderField:@"X-APP-VERSON"];
    [manager.requestSerializer setValue:typetext forHTTPHeaderField:@"Content-Type"];
    
    NSString *httpString = [NSString stringWithFormat:@"%@%@%@/%@/",hostName, addStarAPI, StarID, @"follow"];
    
    
    //    NSLog(@"%@", httpString);
    [manager POST:httpString parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
        // 这里可以获取到目前的数据请求的进度
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        // 请求成功，解析数据
        //        NSLog(@"%@", responseObject);
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers | NSJSONReadingMutableLeaves error:nil];
        [[NSNotificationCenter defaultCenter] postNotificationName:addStar object:nil userInfo:dic];
        //        NSLog(@"%@", dic);
        
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        // 请求失败
        //        NSLog(@"%@", [error localizedDescription]);
    }];
    
    return self;

}





//请求用户quxiao 关注明星
+ (id)requestDeletaFlowStarWithUserID:(NSString *)StarID
{
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    
    [manager.requestSerializer setValue:[UserInfoModel tokenString] forHTTPHeaderField:@"X-AUTH-TOKEN"];
    [manager.requestSerializer setValue:appVersion forHTTPHeaderField:@"X-APP-VERSON"];
    [manager.requestSerializer setValue:typetext forHTTPHeaderField:@"Content-Type"];
    
    NSString *httpString = [NSString stringWithFormat:@"%@%@%@/%@/",hostName, addStarAPI, StarID, @"follow"];
    
    
    
    [manager DELETE:httpString parameters:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        // 请求成功，解析数据
        //        NSLog(@"%@", responseObject);
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers | NSJSONReadingMutableLeaves error:nil];
        
        [[NSNotificationCenter defaultCenter] postNotificationName:addStar object:nil userInfo:dic];
//                NSLog(@"%@", dic);
        
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        // 请求失败
                NSLog(@"%@", [error localizedDescription]);
    }];
    
    return self;

}







+ (id)requestStarTpyeWith:(NSString *)typeID withStarID:(NSString *)starID
{
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    
    [manager.requestSerializer setValue:[UserInfoModel tokenString] forHTTPHeaderField:@"X-AUTH-TOKEN"];
    [manager.requestSerializer setValue:appVersion forHTTPHeaderField:@"X-APP-VERSON"];
    [manager.requestSerializer setValue:typetext forHTTPHeaderField:@"Content-Type"];
    
    NSString *httpString = [NSString stringWithFormat:@"%@%@%@/%@/%@/%@",hostName, addStarAPI, starID, @"tag", typeID, mingxingbiaoqianAPI];
    
    
    //    NSLog(@"%@", httpString);
    [manager GET:httpString parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
        // 这里可以获取到目前的数据请求的进度
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        // 请求成功，解析数据
//                NSLog(@"%@", responseObject);
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers | NSJSONReadingMutableLeaves error:nil];
        [[NSNotificationCenter defaultCenter] postNotificationName:biaoqianzuopin object:nil userInfo:dic];
        //        NSLog(@"%@", dic);
        
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        // 请求失败
        NSLog(@"%@", [error localizedDescription]);
    }];

    return self;
}





@end
